﻿<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../helpproject.xsl" ?>
<topic template="Default" lasteditedby="Geert" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../helpproject.xsd">
  <title translate="true">Unit testing in Silverlight</title>
  <keywords>
    <keyword translate="true">Silverlight</keyword>
    <keyword translate="true">Unit testing</keyword>
  </keywords>
  <body>
    <header>
      <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Unit testing in Silverlight</text></para>
    </header>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">Test driven development (TDD) is hot. It&apos;s so hot that if you are a serious developer, you can&apos;t get around it. This part of the documentation explains how to create the unit tests. If you are interested in how to unit test the services that ship with Catel, read the documentation about </text><link displaytype="text" defaultstyle="true" type="topiclink" href="GS_UnitTesting_Unit_testing_services" styleclass="Normal" translate="true">unit testing the services</link><text styleclass="Normal" translate="true">.</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">The Microsoft Test project template in Microsoft Visual Studio 2010 does not support adding a reference to a Silverlight class library. To unit test a function in a Silverlight class library, it is important to install the </text><link displaytype="text" defaultstyle="true" type="weblink" href="http://silverlight.codeplex.com/releases/view/43528" target="_blank" styleclass="Normal" translate="true">Microsoft Silverlight Toolkit April 2010</link><text styleclass="Normal" translate="true">.</text></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Creating the unit test project</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">After installing the Microsoft Silverlight Toolkit April 2010, you can find a </text><text styleclass="Normal" style="font-style:italic;" translate="true">Silverlight Unit Test Application</text><text styleclass="Normal" translate="true"> project template, under Installed Templates &gt; Visual C# &gt; Silverlight in the </text><text styleclass="Normal" style="font-style:italic;" translate="true">Add New Project</text><text styleclass="Normal" translate="true"> wizard in Microsoft Visual Studio 2010.</text></para>
    <para styleclass="Normal"><image src="unittesting_silverlight_createproject.png" scale="100.00%" styleclass="Image Caption"></image></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">This will add 2 projects to your solution, a [test project] and a [test application] to run the Silverlight unittests in the browser.</text></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Creating your first unit test</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">First add a reference in the [test project] to the Silverlight class library to test. Then you can run the unit test framework and get the web page shown below:</text></para>
    <para styleclass="Normal"><image src="unittesting_silverlight_runall.png" scale="100.00%" styleclass="Image Caption"></image></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Running unit tests outside the browser</text></para>
    <list id="1" type="ol" listtype="decimal" formatstring="%0:s." format-charset="DEFAULT_CHARSET" levelreset="true" legalstyle="false" startfrom="1" styleclass="Normal" style="font-family:Arial; font-size:10pt; color:#000000;">
      <li styleclass="Normal"><text styleclass="Normal" translate="true">Install </text><link displaytype="text" defaultstyle="true" type="weblink" href="http://www.jetbrains.com/resharper/" target="_blank" styleclass="Normal" translate="true">JetBrains resharper</link></li>
      <li styleclass="Normal"><text styleclass="Normal" translate="true">Download the </text><link displaytype="text" defaultstyle="true" type="weblink" href="http://agunit.codeplex.com" target="_blank" styleclass="Normal" translate="true">JetBrains Resharper plugin agunit</link></li>
      <li styleclass="Normal"><text styleclass="Normal" translate="true">Create the folder [%ProgramFiles%\JetBrains\ReSharper\v6.0\Bin\Plugins\AgUnit] if it does not exist.</text></li>
      <li styleclass="Normal"><text styleclass="Normal" translate="true">Extract the agunit zip and add the contents to the folder: [%ProgramFiles%\JetBrains\ReSharper\v6.0\Bin\Plugins\AgUnit].</text></li>
      <li styleclass="Normal"><text styleclass="Normal" translate="true">Open your solution containing the Silverlight test project in Microsoft Visual Studio 2010 and click on the green circle next to your silverlight unittest:</text></li>
    </list>
    <para styleclass="Normal"><image src="unittesting_silverlight_resharper.png" scale="100.00%" styleclass="Image Caption"></image></para>
  </body>
</topic>
